package com.cn.wanxi.thread.model;

import com.cn.wanxi.dto.UserDto;
import com.cn.wanxi.model.PageModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.model.UserModel;
import com.cn.wanxi.service.IUserService;

import java.util.Timer;
import java.util.TimerTask;

public class TestTimer {

    public static void main(String[] args) {
        final int[] a = {0};
        Timer timer = new Timer();

        timer.schedule(new TimerTask() {

            @Override
            public void run() {
                System.out.println(a[0]++);
                if (a[0] == 6) {
                    System.out.println("定时器取消");
//                    timer.cancel();
                    a[0] = 0;
                }
            }
        }, 2000, 2000);
    }
}
